<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">
    let arr1 = [1,2,3,4,5,6]
    let arr2 = [0,2,3,6,8,10]
    console.log(...arr1);//展开一个数组
    let arr3 = [...arr1,...arr2]//连接数组

    //在函数中使用
    function sum(...numbers){
        return numbers.reduce((previousValue,currentValue)=>{
            return previousValue + currentValue
        })
    }
    console.log(sum(1,2,3,4))

    //构造字面量对象是使用展开语法
    let person = {name:'Tom',age:18}
    let person2 = {...person}
    // console.log(...person);//报错，展开运算符不能展开对象
    console.log(person2)

    let person3 = {...person,name:'jeck',address:'地球'}//合并
    console.log(person3)
</script>
</body>
</html>